package cn.iocoder.yudao.module.system.controller.admin.investment;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.InvestmentInsertReqVO;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.InvestmentReqVO;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.InvestmentRespVO;
import cn.iocoder.yudao.module.system.controller.admin.investment.vo.InvestmentUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.investment.SystemInvestment;
import cn.iocoder.yudao.module.system.service.investment.InvestmentService;
import cn.iocoder.yudao.module.system.util.NewDateUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

/**
 * @author 梁富贵
 * @Date 2024/10/10
 **/
@Tag(name = "管理后台 - 招商方")
@RestController
@RequestMapping("/system/investment")
@Validated
public class InvestmentController {
    @Value("${spring.web.resources.static-locations}")
    private String filePath;

    @Resource
    private InvestmentService investmentService;

    @Resource
    private FileService fileService;

    @Schema(description = "管理员获取招商项目列表")
    @PostMapping("/page")
    public PageResult<InvestmentRespVO> getInvestmentPage(@Valid @RequestBody InvestmentReqVO reqVO) {
        return investmentService.getInvestmentPage(reqVO);
    }

    @Schema(description = "招商项目删除")
    @DeleteMapping("/delete")
    public int deleteInvestment(@Valid @RequestParam("ids") List<Integer> ids) {
        return investmentService.deleteInvestment(ids);
    }

    @Schema(description = "招商项目修改")
    @PutMapping("/update")
    @Valid
    public Integer updateInvestment(@ModelAttribute InvestmentUpdateReqVO investmentUpdateReqVO) throws IOException {
        return investmentService.updateInvestment(investmentUpdateReqVO);
    }




    @Schema(description = "招商项目增加")
    @PostMapping("/insert")
    @Valid
    public Integer insertInvestment(@ModelAttribute InvestmentInsertReqVO investmentInsertReqVO) throws IOException {

        return investmentService.createInvestment(investmentInsertReqVO);
    }

}
